import load2 as load

class aclass:
    def __init__(self,className):
        self.mathScore = 0
        self.ChiScore = 0
        self.EngScore = 0

        self.member = 1
        self.className = className

    def avg(self):
        self.mathScore = round(self.mathScore / self.member,2)
        self.ChiScore = round(self.ChiScore / self.member,2)
        self.EngScore = round(self.EngScore / self.member,2)
        self.tot = round(self.mathScore+self.ChiScore+self.EngScore,2)

    def getStr(self):
        print(self.className+','+repr(self.mathScore)+','+repr(self.ChiScore)+','+repr(self.EngScore)+','+repr(self.tot))

allClass={}

for i in range(1,22423):
    School = load.getCell(i, load.School)
    if School != '成武一中':
        continue
    Class = load.getCell(i, load.Class)

    if not Class in allClass.keys():
        allClass[Class]=aclass(Class)
    allClass[Class].mathScore += float(load.getCell(i, load.Math))
    allClass[Class].EngScore += float(load.getCell(i, load.English))
    allClass[Class].ChiScore += float(load.getCell(i, load.Chinese))
    allClass[Class].member += 1

for i,j in allClass.items():
    j.avg()
    j.getStr()